<template>
  <div>
    <FormPanel ref="from" :list="formList" @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />

    <BreakSpace label='操作记录' />
    <FilterTable
      ref="table"
      :columns="columns1"
      :dataSource="tableLists"
      :isSelectColumn="false"
      height='auto'
      :onColumnsChange="columns => this.columns1 = columns"
    >

    </FilterTable>
    <div style="height:47px;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer(1)">关 闭</el-button>

    </div>
  </div>
</template>
<script>
import {getLog } from '@/api/dealerSale/OrderManagement/OrderSubmission/index.js';
import {getflowList,getDealerUser} from '@/api/index.js'
import {getDetail,majorAddressAudit,postrejectCheck,getTypesub,getDiscountDetails,getAmount} from '@/api/omSale/KeyCustomers/PickAddressAudit'
import { dictionary } from '@/utils/dictMixin';
import moment from 'moment'
export default {
  data(){
    this.saveData=null;
    return{
      formList:this.createdFrom(),
      columns1:this.createdTables(),
      fetchParams:{

      },
      fetchApi:()=>{},
      fetchParams:{},
      tableList:[],
      tableLists:[]
    }
  },
  components: {

  },
  props:['rowData'],
  created(){
    this.getDetail(this.rowData)
    this.getLog(this.rowData.orderId)
  },
  mixins:[dictionary],
  methods:{
    createdFrom(){
      return [
        {
          type: 'BREAK_SPACE',
          label: '订单信息',

        },

        {
          type: 'INPUT',
          label: '订货单编号',
          fieldName: 'orderNo',
          placeholder: '请输入',
          disabled:true,
        },
        {
          type: 'DATE',
          label: '当前年月',
          fieldName: 'YearMonth',
          placeholder: '请输入',
          disabled:true,
          dateType:'month',
          initialValue:moment().format('YYYY-MM')
        },
        {
          type: 'SELECT',
          label: '订单状态',
          fieldName: 'orderStatus',
          placeholder: '请选择',
          disabled:true,
          itemList:this.createDictList('6002')
        },
        {
          type: 'SELECT',
          label: '订单类型',
          fieldName: 'orderType',
          placeholder: '请选择',
          disabled:true,
          itemList:this.createDictList('6006')
        },
        {
          type: 'SELECT',
          label: '订单细分类型',
          fieldName: 'orderDetailType',
          placeholder: '请选择',
          disabled:true,
          itemList:[],
        },
        {
          type: 'INPUT',
          label: '订单经销商',
          fieldName: 'dealerName',
          placeholder: '请选择',
          disabled:true,
        },
        {
          type: 'INPUT',
          label: '产品代码',
          fieldName: 'productCode',
          placeholder: '请选择',
          disabled:true,
        },
        {
          type: 'INPUT',
          label: '产品名称',
          fieldName: 'productName',
          placeholder: '请选择',
          disabled:true,
        },
        {
          type: 'INPUT',
          label: '资金类型',
          fieldName: 'accountTypeName',
          placeholder: '请选择',
          disabled:true,
          rules: [{ required: true, message: '请选择', trigger: 'blur' }],
        },
        {
          type: 'INPUT',
          label: '销售订单号',
          fieldName: 'doNo',
          placeholder: '请选择',
          disabled:true,
        },
        {
          type: 'INPUT',
          label: 'VIN码',
          fieldName: 'vin',
          placeholder: '请选择',
          disabled:true,
        },
        {
          type: 'INPUT',
          label: '修改前收车地址',
          fieldName: 'beforeAddress',
          placeholder: '请选择',
          disabled:true,
        },
        {
          type: 'INPUT',
          label: '修改后收车地址',
          fieldName: 'afterAddress',
          placeholder: '请选择',
          disabled:true,
        },

        {
          type: 'INPUT',
          label: '修改前联系人',
          fieldName: 'beforeLinkMan',
          placeholder: '请选择',
          disabled:true,
        },
        {
          type: 'INPUT',
          label: '修改后联系人',
          fieldName: 'afterLinkMan',
          placeholder: '请选择',
          disabled:true,
        },
        {
          type: 'INPUT',
          label: '修改前联系电话',
          fieldName: 'beforeLinkPhone',
          placeholder: '请选择',
          disabled:true,
        },
        {
          type: 'INPUT',
          label: '修改后联系电话',
          fieldName: 'afterLinkPhone',
          placeholder: '请选择',
          disabled:true,
        },

        {
          type: 'TEXT_AREA',
          label: '审核意见',
          fieldName: 'auditOpinion',
          selfCols:3,
          disabled:true,
          rules: [{ required: true, message: '请选择', trigger: 'blur' }],
        },

      ]
    },
    createdTables(){
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '单据执行前状态',
          dataIndex: 'beforeOrderStatus',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('6043'),
          render: p => {
            return <span>{this.createDictText(p.row.beforeOrderStatus, '6043')}</span>;
          }

        },
        {
          title: '单独执行后状态',
          dataIndex: 'afterOrderStatus',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: this.createDictList('6043'),
          render: p => {
            return <span>{this.createDictText(p.row.afterOrderStatus, '6043')}</span>;
          }
        },
        {
          title: '操作人员',
          dataIndex: 'createdName',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
        {
          title: '操作时间',
          dataIndex: 'createdAt',
          sorter: true,
          filter: true,
          filterType: 'date-range',
        },
        {
          title: '操作类型',
          dataIndex: 'operationType',
          sorter: true,
          filter: true,
          filterType: 'input',
          render: (p) => {
            return <span >{p.row.operationType}</span>;
          },
        },
        {
          title: '审批意见',
          dataIndex: 'auditOpinion',
          sorter: true,
          filter: true,
          filterType: 'input',
        },
      ]
    },
    async getDetail(data){
      for(let i in data){
        this.formList.map(x=>{
          if(x.fieldName==i){
            x.initialValue=data[i]
          }
        })
      }
      this.getNotPage(res.data.orderType)
      console.log(res);
    },
    async getDiscountDetails(data){
      let json={policyId:data.policyId,
        singleAmount:data.singleAmount,
        subsidyAmount:data.subsidyAmount
        }
      let res=await getDiscountDetails(json)
      this.tableList=res.data||[]
    },
    async getNotPage(orderType){
      let list=await getTypesub({orderType:orderType})
        this.formList.map(x=>{
          if(x.fieldName=='orderDetailType'){
            x.itemList=list.data.map(x=>({text:x.subName,value:x.id}))
          }
        })
    },
    changeHandle(val){
      this.saveData=val;
    },
    async closeDrawer(type){
      if(type==1){
        this.$emit('close')
      }
    },

      async getLog(id){
        let res=await getLog({orderId:id})
        console.log(res,'2')
        this.tableLists=res.data||[];
      }
  }
}
</script>
